package NW_Hybrid;

import java.util.List;

import NWPackage.Calculations;
import NWPackage.Cell;
import NWPackage.NW_Main;
import NWPackage.PairPreferdCandidateMatrix;
import NWPackage.ProbabilitiesMatrix;
import NWPackage.Protocol;
import NWPackage.QueryFinderAlg;
import NW_MC.MonteCarlo;
import NW_Random.MyRandom;

public class Hybrid implements QueryFinderAlg {

	private int number_of_random_q;
	private MonteCarlo mc = new MonteCarlo();
	private MyRandom random = new MyRandom();
	
	/***
	 * 
	 * @param precentage
	 * get the precentage number for  Random queries to perform (out of total queries)
	 */
	public Hybrid(double precentage)
	{
		//calc Total number of queries
		int numOfQueries = Calculations.calcNumberOfQueries();
		this.number_of_random_q = (int) (numOfQueries * precentage);
		
	}
	@Override
	public Cell FindNextQuery(ProbabilitiesMatrix probMatrix,PairPreferdCandidateMatrix pairsPreferredMatrix,List<String> optionalWinners, Protocol protocol) throws Exception {
		if (this.number_of_random_q > 0)
		{
			this.number_of_random_q--;
			return random.FindNextQuery(probMatrix, pairsPreferredMatrix, optionalWinners,protocol);	
		}
		else
			return mc.FindNextQuery(probMatrix, pairsPreferredMatrix, optionalWinners, protocol);
	}

}
